<template>
  <div class="mine">
    <van-nav-bar title="个人中心">
      <template #left> <div class="set iconfont icon-shezhi"></div> </template>
      <template #right>
        <div class="set iconfont icon-xiaoxizhongxin" @click="toMessage"></div>
      </template>
    </van-nav-bar>
    <div class="personalCenter">
      <div class="myProfile">
        <img :src="login ? avatar : unavatar" alt="" />
      </div>
      <div class="myinfo">
        <div class="unLoginInfo" v-if="!login">
          <b @click="$router.push('/login')">点击登录</b>
        </div>
        <div class="loginInfo" v-else>
          <span>{{ name }}</span
          ><br />
          <p>{{ tel }}</p>
        </div>
      </div>
      <div
        class="toInformation iconfont icon-xiayiyeqianjinchakangengduo"
      ></div>
    </div>
    <div class="myOrder">
      <span>我的订单</span>
      <hr />
      <div class="icon">
        <div class="iconfont icon-daifukuan2 icon_img"><p>待付款</p></div>
        <div class="iconfont icon-31daishouhuo icon_img"><p>待发货</p></div>
        <div class="iconfont icon-daishouhuo1 icon_img"><p>待收货</p></div>
        <div class="iconfont icon-daipingjia01 icon_img"><p>待评价</p></div>
        <div class="iconfont icon-tuikuan icon_img"><p>退款/售后</p></div>
      </div>
    </div>
    <div class="myServer">
      <span>我的订单</span>
      <div class="icon">
        <div class="iconfont icon_img icon-81"><p>门店核销</p></div>
        <div class="iconfont icon_img icon-tuiguang"><p>我的推广</p></div>
        <div class="iconfont icon_img icon-qianbao2"><p>我的钱包</p></div>
        <div class="iconfont icon_img icon-flower"><p>我的收藏</p></div>
        <div class="iconfont icon_img icon-shouhuodizhiyebianji">
          <p>收获地址</p>
        </div>
        <div class="iconfont icon_img icon-youhuijuan-xianxing">
          <p>优惠劵</p>
        </div>
        <div class="iconfont icon_img icon-jifen"><p>我的积分</p></div>
        <div class="iconfont icon_img icon-kanjia1"><p>我的砍价</p></div>
        <div class="iconfont icon_img icon-shezhi-xianxing">
          <p>会员设置</p>
        </div>
        <div class="iconfont icon_img icon-bangzhu1"><p>帮助中心</p></div>
        <div class="iconfont icon_img"></div>
        <div class="iconfont icon_img"></div>
      </div>
    </div>
    <button @click="exit" v-if="user">退出登录</button>
  </div>
</template>

<script>
import { mapState, mapGetters, mapMutations } from "vuex";
import { Toast, Dialog } from "vant";
import { getStorage } from "@/utils/storage";
export default {
  name: "mine",
  computed: {
    ...mapState(["user"]),
    ...mapGetters(["login"]),
  },
  data() {
    return {
      name: "",
      unavatar: require("../../assets/img/content_img/2.5D-C-个人专家.png"),
      avatar: "",
      tel: "",
      order_count: [],
    };
  },
  created() {
    this.init();
  },
  methods: {
    ...mapMutations(["logout"]),
    init() {
      if (!this.login) {
        return;
      }
      //获取本地数据
      const { order_count, tel, name, avatar } = getStorage("user");
      this.order_count = order_count;
      this.tel = tel;
      this.name = name;
      this.avatar = avatar;
    },
    exit() {
      Dialog.confirm({
        title: "温馨提示",
        message: "您确认退出登录吗？",
      })
        .then(() => {
          this.logout();
          this.$router.push("/login");
        })
        .catch(() => {});
    },
    toMessage() {
      if (!this.user) {
        Toast.fail("请先登录哦亲");
        setTimeout(() => {
          this.$router.push("/login");
        }, 1000);

        return;
      } else {
        Toast.success("消息详情页");
        return;
      }
    },
  },
};
</script>

<style lang="less" scoped>
.mine {
  .set {
    font-size: 40px;
    color: #fff;
  }
  /deep/.van-nav-bar__title {
    color: #fff;
  }
  .van-nav-bar {
    background-color: #08dbdb;
  }
  .personalCenter {
    width: 100%;
    height: 180px;
    // border: #08dbdb solid 1px;
    background-color: #08dbdb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    .myProfile {
      width: 120px;
      height: 120px;
      // background-color: #fff;
      border-radius: 50%;
      border: #fff solid 10px;
      margin-left: 50px;
      background-color: #e6dfdf;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .myinfo {
      width: 200px;
      height: 80px;
      // border: #f00 solid 1px;
      margin-right: 190px;
      // font-size: 30px;
      // text-align: center;
      b {
        font-size: 38px;
        font-weight: 700;
        margin-top: 10px;
        line-height: 80px;
      }
      span {
        font-size: 30px;
        font-weight: 700;
      }
      p {
        font-size: 28px;
        font-weight: 600;
        margin-top: 8px;
      }
    }
    .toInformation {
      font-size: 70px;
      margin-right: 50px;
      font-weight: 700;
    }
  }
  .myOrder {
    padding-top: 20px;
    height: 213px;
    width: 713px;
    margin: 20px;
    background-color: #fff;
    span {
      font-size: 33px;
      color: #5f6061;
      margin-left: 26px;
    }
    hr {
      color: #5f6061;
    }
    .icon {
      display: flex;
      justify-content: space-between;
      color: #5f6061;
      .icon_img {
        width: 130px;
        font-size: 70px;
        // border: #08dbdb 1px solid;
        text-align: center;

        p {
          font-size: 26px;
        }
      }
    }
  }
  .myServer {
    padding-top: 20px;
    width: 713px;
    height: 497px;
    box-sizing: border-box;
    background-color: #fff;
    margin: 20px;
    margin-top: 0;
    // border: #f00 solid 1px;
    span {
      font-size: 33px;
      color: #5f6061;
      margin-left: 26px;
      margin-top: 20px;
    }
    .icon {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      color: #5f6061;
      margin-top: 20px;
      .icon_img {
        width: 170px;
        font-size: 70px;
        // border: #08dbdb 1px solid;
        text-align: center;
        margin-bottom: 20px;
        p {
          font-size: 26px;
          margin-top: 10px;
        }
      }
    }
  }
}
</style>
